package com.my.json.sensitive.annotation;

import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.my.json.sensitive.config.SensitiveInfoSerialize;
import com.my.json.sensitive.enums.SensitiveType;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * json中敏感字过滤
 * 使用方法
 *   @SensitiveField(type = SensitiveType.CHINESE_NAME)
 *   private String personName;
 *
 *      ObjectMapper maskMapper = new ObjectMapper();
 *      System.out.println(maskMapper.writeValueAsString(inputXml));
 *
 * @author hexinglin
 * @created 2021-12-29 15:48
 **/
@Target({ElementType.FIELD, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@JsonSerialize(
        using = SensitiveInfoSerialize.class
)
@JacksonAnnotationsInside
public @interface SensitiveField {
    SensitiveType type() default SensitiveType.NULL;

    int prefix() default 4;

    int suffix() default 3;

    int split() default 3;
}
